import URL.Constants;
import address.Address;
import bean.HotVideComm;
import bean.HotVideo;
import com.alibaba.fastjson.JSONObject;
import requerst.HttpUt;
import service.*;

import java.security.KeyPair;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

public class Test {
/**
 * @author: dae
 * @email: 675116529@qq.com
 * @phone: 15270029507
 * @DateTime: 2021/12/7 9:01
 **/




    public static void main(String[] args) {

        while (true) {
            System.out.println("-------------------------------------------------------欢迎使用本程序----------------------------------------------------------------------------------------");
            System.out.println("输入需要使用的功能编号");
            System.out.println("api类");
            System.out.println("1 ： 热门视频  ； 2 ：历史上的今天 ； 3 ：老黄历；");
            System.out.println("比特币通信类");
            System.out.println("4 : getbestblockhash ; 5 : getblockcount ; 6 : getconnectioncount ; 7 : getdifficulty ; 8 : getaddednodeinfo ;");
            System.out.println("比特币地址");
            System.out.println("9 : 比特币地址获取并验证其合法性");
            System.out.println("10 ： 退出 ;");
            Scanner scanner = new Scanner(System.in);
            int a = scanner.nextInt();
            switch (a) {
                case 1:
                    //功能1 的热门视频
                    HotVideoService hotVideoService =new HotVideoService();
                    System.out.print("输入想看的文章数");
                    Scanner scan2 = new Scanner(System.in);
                    int size = scan2.nextInt();
                    Constants.size = size;
                  //  List<HotVideo> hotVideoList = hotVideoService.getHotVideo();
                  //  for (HotVideo hotVideo :hotVideoList){
                  //      System.out.println(hotVideo.author);
                     //   System.out.println(hotVideo.hot_value);

                    if (hotVideoService.getHotVideo() ==null){
                        System.out.println("输入数据错误，请按给定格式");
                    }else {
                        System.out.println(hotVideoService.getHotVideo());
                    }
                    break;
                case 2:
                    //功能2 历史上的今天
                    System.out.print("输入需要查询的历史上的今天日期，例如 1/2;12/3");

                    Scanner scan1 = new Scanner(System.in);
                    String Lst_da = scan1.next();
                    Constants.da = Lst_da;
                    LsjtService lsjtService = new LsjtService();

                    if (lsjtService.getLsjt() ==null){
                        System.out.println("输入数据错误，请按给定格式");
                    }else {
                        System.out.println(lsjtService.getLsjt());
                    }
                    break;
                case 3:
                    //功能3 老黄历
                    System.out.print("输入需要查询的老黄历日期，例如 2021-12-8");
                    Scanner scan = new Scanner(System.in);
                    String Lhl_da = scan.next();
                    Constants.Lhl_data = Lhl_da;
                    LhlService lhlService = new LhlService();
                    if (lhlService.getLhl()==null){
                        System.out.println("输入数据错误，请按给定格式");
                    }else {
                        System.out.println(lhlService.getLhl());
                    }
                    break;
                case 4:
                    //功能4 getbestblockhash
                    System.out.println("返回Bitcoin Core获得的 getbestblockhash 的值");
                    GetBestBlockHash getBestBlockHash =new GetBestBlockHash();
                    System.out.println(getBestBlockHash.getBestBlockHash());
                    break;
                case 5:
                   // getblockcount
                    System.out.println("返回Bitcoin Core获得的 getblockcount 的值");
                    GetBlockCount getBlockCount =new GetBlockCount();
                    System.out.println(getBlockCount.getBlockCount());
                    break;
                case 6:
                    //功能6 getconnectioncount
                    System.out.println("返回Bitcoin Core获得的 getconnectioncount 的值");
                    GetConnectioncount getConnectioncount =new GetConnectioncount();
                    System.out.println(getConnectioncount.getConnectIoncount());
                    break;
                case 7:
                    //功能7 getdifficulty
                    System.out.println("返回Bitcoin Core获得的 getdifficulty 的值");
                    GetDifficulty getDifficulty =new GetDifficulty();
                    System.out.println(getDifficulty.getDifficulty());
                    break;
                case 8:
                    //功能8 getaddednodeinfo
                    System.out.println("返回Bitcoin Core获得的 getaddednodeinfo的值");
                    GetAddednodeinfo getAddednodeinfo =new GetAddednodeinfo();
                    System.out.println(getAddednodeinfo.getAddednodeinfo());
                    break;
                case 9:
                    //功能9 比特币地址并验证其合法性
                    Address addr = new Address();
                    KeyPair keyPair = addr.genrateKeys();
                    String Address =  addr.newAddress(keyPair);
                    System.out.println("比特币地址:");
                    System.out.println(Address);
                    boolean isVaalid = addr.validateAdder(Address);
                    System.out.println("true为合法，false为不合法:");
                    System.out.println(isVaalid);
                    break;
                case 10:
                    //功能10 退出
                    System.out.println("--------------------------------------欢迎下次使用----------------------------");
                          System.exit(10);

                    break;
                default:
                    System.out.println("怎么啥都不选呢");
                    break;

            }

        }
    }



}